package ace.module.oauth2.server.sdk.core.feign.impl;

import ace.cmp.core.model.R;
import ace.cmp.openfeign.security.oauth2.core.config.FeignInternalServerOauth2SecurityConfig;
import ace.module.common.api.annotation.ApiRemoteProxyPriority;
import ace.module.oauth2.server.api.model.dto.Oauth2RegisteredClientDto;
import ace.module.oauth2.server.sdk.core.constant.SdkConstant;
import ace.module.oauth2.server.sdk.core.feign.Oauth2RegisteredClientFeignApi;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * oauth2 客户端 rpc feign.
 *
 * @author Caspar
 */
@FeignClient(
    name = "${spring.cloud.openfeign.client.config.oauth2RegisteredClientFeign.name:" + SdkConstant.FEIGN_SERVICE_NAME + "}",
    contextId = "oauth2RegisteredClientFeign",
    path = Oauth2RegisteredClientFeign.PATH,
    configuration = FeignInternalServerOauth2SecurityConfig.class,
    primary = false
)
@ApiRemoteProxyPriority
public interface Oauth2RegisteredClientFeign extends Oauth2RegisteredClientFeignApi {
  String PATH = "${spring.cloud.openfeign.client.config.oauth2RegisteredClientFeign.path:/oauth2-server/oauth2-registered-client/rpc}";

  @GetMapping("/getByClientId")
  @Operation(summary = "获取已经注册客户端,根据client id")
  R<Oauth2RegisteredClientDto> getByClientId(@Valid @NotEmpty @RequestParam("clientId") String clientId);
}
